{% extends "./base.html" %}
{% url 'loaduser-view' as loaduser_url %}

{% block content %}
<script type="text/javascript" src="/static/js/wmadmin.js"></script>
        <div class="header">

            <h1 class="page-title">资产管理</h1>
                    <ul class="breadcrumb">
            <li><a href="/">首页</a> </li>


            <li class="active">设备维护记录</li>
                        <input class="layui-btn layui-btn-mini" type="button" name="Submit" onclick="javascript:history.back(-1);" value="返回上一页">
        </ul>

        </div>
        <div class="main-content">

<div class="btn-toolbar list-toolbar">

 <form  role="form" method="GET" action="{% url 'repairinfosearch-view' %}" style="float: left">
 {% csrf_token %}
    <input placeholder="请输入搜索关键词" type="text"  class="form-control" id="s" name="word"  style="width:200px;float: left;">


 <select name="wordtype">
    <option value="" style="color: red">资产编号：</option>
     {% if assetdetail_list %}
         {% for obj in assetdetail_list %}
             <option id="d" value="{{ obj.itno }}">{{ obj.itno }}</option>
         {% endfor %}

     {% endif %}
 </select>

 <select name="wordbrand">
    <option value="" style="color: red">是否完成：</option>
<option value="1">完成：</option>
     <option value="0">未完成：</option>
 </select>


 <button class="btn btn-primary" >搜 索</button>
     {% if count %}
     一共搜索到 <a style="color: red">{{ count }}</a> 条记录 |  {% endif %}共<a style="color: red"> {{ allcount }} </a>条

</form>
<div style="float: right">


    <a href="{% url 'addrepairinfo-view' %}" class="btn btn-primary"><i class="fa fa-plus"></i> 添加使用记录</a>

    <a href="#" class="btn btn-default" onclick="msg()">导入数据</a>

    <input id="openexcelfile" type="file" name="openexcelfile" style="display: none;" />

    <a href="{% url 'loadrepairinfo-view' %}" class="btn btn-default">导出数据</a>
      <input id="yourinputname" type="file" name="yourinputname" value="上传" style="display: none;" />
    </div>
  <div class="btn-group">
  </div>
</div>
<table class="table table-striped table-bordered table-hover">
  <thead>
    <tr>
      <th width="15%">IT资产编号</th>
      <th width="10%">维护开始时间</th>
        <th width="10%">维护结束时间</th>

         <th width="30%">维护内容说明</th>
        <th width="10%">是否完成</th>
         <th width="10%">维护人员</th>
        <th width="10%">维护人电话</th>



         <th>操作</th>

    </tr>
  </thead>
  <tbody>
  {% with obj_list as repair_list %}

  {% if repair_list %}
      {% for obj in repair_list %}
           <tr>
      <td><a title="点击修改此条信息" href="/repairinfo/{{ obj.id }}"> {{ obj.itno }}</a></td>
      <td>{{ obj.start_time }}</td>
      <td> {{ obj.end_time }}</td>

      <td> {{ obj.repinfo }}</td>
      <td> {% if obj.issure  %}{{ "完成" }}{% else %}{{ '未完成' }}{% endif %}</td>
      <td> {% if not obj.whorep  %}{{ "" }}{% else %}{{ obj.whorep }}{% endif %}</td>
      <td> {% if not obj.whophone  %}{{ "" }}{% else %}{{ obj.whophone }}{% endif %}</td>


      <td>
<a title="修改" href="/repairinfo/{{ obj.id }}"><i class="fa fa-pencil"></i></a>&nbsp;&nbsp;
<a title="删除" href="#delModal{{ obj.id }}" role="button" data-toggle="modal"><i class="fa fa-trash-o"></i></a>


    <div class="modal small fade" id="delModal{{ obj.id }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

<form id="delmodelform{{ obj.id }}" method="post" action="/delrepairinfo/{{ obj.id }}/" >
 {% csrf_token %}
  <div class="modal-dialog">

    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <a style="color:red;font-size: x-large">删除维护记录</a>
        </div>

        <div class="modal-body">
            <p class="error-text"><i class="fa fa-warning modal-icon"></i>您确定要删除  <a style="color: red">{{ obj.itno }}</a>的维护记录<br>如要恢复请登录管理员后台操作</p>
        </div>

        <div class="modal-footer">
            <button  class="btn btn-danger" data-dismiss="modal" onclick="submitForm('{{ obj.id }}');">Delete</button>
            <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>

        </div>
      </div>
    </div>
</form>
</div>


      </td>
    </tr>
      {% endfor %}


  {% endif %}
{% endwith %}
  </tbody>

</table>





<script>
function msg() {
    layer.msg('赞不支持上传维护记录<br>请手动添加！', {
        time: 5000, //5s后自动关闭
        btn: ['明白了']
    });
}
  function submitForm(e) {

                document.getElementById("delmodelform"+e).submit();

     }

function del_userjs()
{
    var getid = document.getElementById("asset").innerHTML;

    layer.confirm('确认删除资产：（'+getid+"）    吗？", {icon: 3, title:'提示:删除后不可恢复！'}, function(index){
  //do something
  $("#del_user").submit();
  layer.close(index);
});





}
</script>

<!--分页 -->

        {% if obj_list %}
            <div  style="position:absolute;bottom:0px;">
        {% include 'include/pagination.html' %}
            </div>
        {% endif %}




</div>

{% endblock %}